<template>
  <div id="service-list">
  		<div class="page-header">
  			评估表列表
  		</div>
      <el-row style="margin-bottom: 15px" :gutter="20">
          <!--<el-col :span="4">-->
              <!--<wt-select-->
                      <!--v-model="input"-->
                      <!--:multiple="false"-->
                      <!--:query="query_doctor"-->
                      <!--ref = 'select'-->
                      <!--placeholder='请选择医生姓名进行查询'-->
              <!--&gt;</wt-select>-->
              <!--</el-col>-->
              <!--<el-col :span="5">-->
              <!--<el-select v-model="service_type" placeholder="请选择评估表状态进行查询">-->
                  <!--<el-option-->
                    <!--v-for="item in service_types"-->
                    <!--:key="item.value"-->
                    <!--:label="item.text"-->
                    <!--:value="item.value"-->
                  <!--&gt;-->
                  <!--</el-option>-->
              <!--</el-select>-->
          <!--</el-col>-->
           <el-col :span="9">
              <el-select v-model="bmi_grade" placeholder="请选择患者会员等级进行查询">
                  <el-option
                    v-for="item in grades"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
              </el-select>
          </el-col>
          <el-col :span="12">
              <el-input
                  v-model="paramsData.search_key"
                  placeholder="患者姓名|身份证|手机号|医生姓名"
                  @keyup.enter.native="search"
              ></el-input>
              <!--<wt-keyword-search-->
                      <!--placeholders="患者姓名|身份证|手机号|医生姓名"-->
                      <!--:query="service.query_doctor"-->
              <!--&gt;-->

              <!--</wt-keyword-search>-->
          </el-col>
          <el-col :span="2">
              <el-button type="primary" icon="search" @click="search">搜索</el-button>
          </el-col>
      </el-row>
      <wt-model-table
              :model="service"
              :allow-edit="false"
              :allow-remove="false"
              :allow-add="false"
              :auto-load="true"
              :params-data="paramsData"
              ref="table"
              :page-param = "pageParam"
      >
          <el-table-column
                  label="操作"
                  min-width="120"
                  fixed="right">
              <template scope="scope">
                  <router-link :to="{name:'service-detail',query:{user_id:user_id.toString(),service_compose_id:scope.row.sc_id}}"><el-button size="small" icon="document">详情</el-button></router-link>
              </template>
          </el-table-column>
      </wt-model-table>
  </div>
</template>

<script>
import Vue from "vue"
import ElementUI from 'element-ui'
import Service from '../model/service'
import ModelTable from 'winged/components/wt-model-table'
import WtPatientClass from '../../Resources/components/wt-patient-class'
import WtIsImgs from '../../Resources/components/wt-is-imgs'
import Select from '../../../Resources/components/wt-select'
import Code from '../utils/Code'
Vue.use(ElementUI);
Vue.component(ModelTable.name, ModelTable);
Vue.component(Select.name, Select);
Vue.component(WtPatientClass.name, WtPatientClass);
Vue.component(WtIsImgs.name, WtIsImgs);
export default {
	components: {ModelTable},
	name: 'welcome',
    metaInfo: { titleTemplate: 'Welcome | %s' },
	props:{
		list:{
			type:Array,
			default:function () {
                return []
			}
        },
        pageParam:{
            type: String,
            default:'page_index'
        },
        pageSize:{
            type: String,
            default: '10'
        }
	},
  data: () => ({
    title: 'Laravel',
    service:Service,
    input:'',
    service_types:[],
    service_type:'',
    paramsData:{
        order_status: '',
        doctor_user_id: '',
        search_key: '',
        bmi_grade: ''
    },
    query_doctor: {
      method: 'DRONE',
      url: 'evaluation/user_info/get_doctor_list',
      transfer: true,
      label: 'name',
      value: 'doctor_user_id',
      extraParams:['department_id'],
      resultParam:'doctors',
    },    
    user_id: LA.userInfo['info.id'],
    sizeParam: 'page_size',
    grades:[],
    bmi_grade:''
  }),
    methods:{
		search(){
			this.paramsData.order_status = this.service_type.toString();
			this.paramsData.doctor_user_id = this.input.toString();
            this.paramsData.bmi_grade = this.bmi_grade.toString();
			this.$nextTick(() => {
				this.$refs.table.buildExtraParams()
			})
        }
    },
    created(){
		this.paramsData.order_status = this.service_type;
		this.paramsData.doctor_user_id = this.input;
        this.paramsData.bmi_grade = this.bmi_grade;
		let arr = [];
		for (let i = 0; i < this.service.service_type.length; i++){
				arr.push({
					text:Code.order_status(this.service.service_type[i].current_order_status),
					value:this.service.service_type[i].current_order_status
				});
            }
            let res = []
            for (let i = 0; i < arr.length; i++){
			    let flag = false
			    for(var j = (i+1); j < arr.length; j++){
					if(arr[i].value == arr[j].value){
                        flag = true
                    }
                }
                if(!flag){
			    	res.push(arr[i])
                }
            }
        this.service_types = res;
        let array = [];
        for(let e = 0; e < this.service.bmi_grades.length; e++){
            array.push({
                label:this.service.bmi_grades[e]=="未分组"?this.service.bmi_grades[e]:this.service.bmi_grades[e]+'会员',
                value:this.service.bmi_grades[e]
            })
        }
        this.grades = array
    }
}
</script>

<style lang="less">
#service-list{
	.top-right {
		position: absolute;
		right: 10px;
		top: 18px;
	}

	.title {
		font-size: 85px;
	}
	.el-pagination{
		text-align:center;
	}
    .el-select{
        width: 90%
    }
}

</style>
